package cn.ren.hai.base.controller;

import cn.ren.hai.base.entity.RhDict;
import cn.ren.hai.base.service.RhDictService;
import cn.ren.hai.core.entity.PageInfo;
import cn.ren.hai.core.entity.QueryPage;
import cn.ren.hai.core.response.ResponseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;


/**
 * 字典(RhDict)表控制层
 *
 * @author makejava
 * @since 2022-01-23 03:14:55
 */
@Api(tags = "字典(RhDict)") 
@Validated
@RestController 
@RequestMapping("/api/base/rhDict")
public class RhDictController {
 
    private final RhDictService rhDictService;
    
    @Autowired
    public RhDictController(RhDictService rhDictService) {
        this.rhDictService = rhDictService;
    }

    /**
     * 查询分页数据
     */
    @ApiOperation(value = "查询分页数据")
    @PostMapping(value = "/getList")
    public ResponseBean<PageInfo<RhDict>> getList(@RequestBody QueryPage<RhDict> page) {
        return new ResponseBean<>(rhDictService.list(page));
    }

    /**
     * 根据id查询
     */
    @ApiOperation(value = "根据id查询数据")
    @GetMapping(value = "/getById")
    public ResponseBean<RhDict> getById(@RequestParam("id") Serializable id) {
        return new ResponseBean<>(rhDictService.getById(id));
    }

    /**
     * 新增
     */
    @ApiOperation(value = "新增/修改 数据")
    @PostMapping(value = "/saveUpdate")
    public ResponseBean<Boolean> saveUpdate(@RequestBody RhDict rhDict) {
        return new ResponseBean<>(rhDictService.saveOrUpdate(rhDict));
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除数据")
    @DeleteMapping(value = "/del")
    public ResponseBean<Boolean> delete(@RequestParam("id") Serializable id) {
        return new ResponseBean<>(rhDictService.removeById(id));
    }

    

    
}

